package com.examplemartin.jpademo.util;

public class ValidateMember {

    public static Boolean isEmpty(Object obj){
        if (obj == null) return true;

        if(isString(obj)){
            String str = obj.toString().trim();
            return str.equals("");
        }
        return false;
    }




    public static Boolean isString(Object obj){
        return obj instanceof String;
    }

    public static Boolean isInteger(Object obj){
        return obj instanceof Integer;
    }

    public static Boolean isLong(Object obj){
        return obj instanceof Long;
    }

    public static Boolean isDouble(Object obj){
        return obj instanceof Double;
    }

    public static Boolean gtValue(Object obj,Double value){
        if(!isInteger(obj)||isLong(obj)||isDouble(obj)) return false;

        double d = Double.parseDouble(obj.toString());
        return !(d < value);
    }

    public static Boolean ltValue(Object obj,Double value){
        if(!isInteger(obj)||isLong(obj)||isDouble(obj)) return false;

        double d = Double.parseDouble(obj.toString());
        return !(d > value);
    }
}
